package publisherSubscriber;

import org.omg.CORBA.Any;

import cosEventComm.Disconnected;
import cosEventComm.PullSupplier;

public class ActionExecutor implements Runnable {
	private PullSupplier consumer;
	private Action action;
	

	protected ActionExecutor(PullSupplier consumer) {
		super();
		this.consumer = consumer;
	}

	public void setAction(Action action) {
		this.action = action;
	}

	@Override
	public void run() {
		while(true){
			Any any = null;
			try {
				any = consumer.pull();
			} catch (Disconnected e) {				
				e.printStackTrace();
			}	
			if(action != null){
				action.actionPerformed(any);
			}
		}

	}

}
